package com.jobs.jsonDemo;

import cn.hutool.core.io.FileUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;

/**
 * @Author 王博
 * @DateTime 2024-08-08 10:39
 */
public class ReadJsonDemo {
    public static void main(String[] args) {
        //读取文件
        String json = FileUtil.readString(new File("src/main/java/com/jobs/jsonDemo/json.json"), "UTF-8");
        JSONArray jsonArray = new JSONArray(json);
        List<String> orderSnList = new ArrayList<>();
        jsonArray.forEach(jsonObject->orderSnList.add("\""+((JSONObject)jsonObject).get("orderSn").toString()+"\""));
        String join = String.join(",", orderSnList);
        System.out.println(join);
        System.out.println(orderSnList.size());
    }
}
